package com.example.demo;

import com.example.demo.component.BeanLifeComponent;
import com.example.demo.model.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		ApplicationContext context = SpringApplication.run(DemoApplication.class, args);
//		User user = context.getBean(User.class);
//		user.setName("lisi");
//		System.out.println(user);
//		System.out.println("当前对象地址: "+System.identityHashCode(user));
//
//		User user2 = context.getBean(User.class);
//		System.out.println(user);
//		System.out.println("当前对象地址: "+System.identityHashCode(user2));
		BeanLifeComponent lifeComponent = context.getBean(BeanLifeComponent.class);
		lifeComponent.use();
//		((AbstractApplicationContext)context).destroy();
	}

}
